home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
UPC12BS1.ZIP
/
MAIL
/
MAILSEND.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-03
|
36KB
|
1,020 lines
/*--------------------------------------------------------------------*/
/* m a i l s e n d . c */
/* */
/* Subroutines for sending mail for UUPC/extended */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1989-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by */
/* the UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* RCS Information */
/*--------------------------------------------------------------------*/
/*
* $Id: mailsend.c 1.6 1993/10/04 03:57:20 ahd Exp $
*
* Revision history:
* $Log: mailsend.c $
* Revision 1.6 1993/10/04 03:57:20 ahd
* Clarify error message
*
* Revision 1.5 1993/08/02 03:24:59 ahd
* Further changes in support of Robert Denny's Windows 3.x support
*
* Revision 1.4 1993/07/31 16:26:01 ahd
* Changes in support of Robert Denny's Windows support
*
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "arpadate.h"
#include "expath.h"
#include "execute.h"
#include "hlib.h"
#include "mlib.h"
#include "alias.h"
#include "mail.h"
#include "maillib.h"
#include "mailblib.h"
#include "mailsend.h"
#include "safeio.h"
#include "address.h"
/*--------------------------------------------------------------------*/
/* Local function prototypes */
/*--------------------------------------------------------------------*/
static char *ExplodeAlias(char *header ,
const char *alias,
FILE *stream,
const boolean resent);
static void PutHead( const char *label,
const char *operand,
FILE *stream,
const boolean resent);
static boolean Append_Signature(FILE *mailbag,
const boolean alternate);
static void Prompt_Input( char *tmailbag,
FILE *fmailbag,
char *subject,
const int current);
static boolean Subcommand( char *buf,
FILE *fmailbag,
char *tmailbag,
char *subject,
const int current_msg);
static void CopyOut( const char* input);
static void filter( char *tmailbag, char *command);
static char *GetString( char *input);
currentfile(); /* Define current file for panic() */
/*--------------------------------------------------------------------*/
/* E x p l o d e A l i a s */
/* */
/* Resolves an alias, exploding it into a list if needed. */
/*--------------------------------------------------------------------*/
static char *ExplodeAlias(char *header ,
const char *alias,
FILE *stream,
const boolean resent)
{
char *fullname;
char buffer[LSIZE];
if ((alias == NULL) || (strlen(alias) == 0))
{
printmsg(0,"ExplodeAlias: NULL or empty string for argument");
panic();
}
fullname = AliasByNick(alias);
printmsg(4,"Processing alias '%s', result '%s'", alias,
(fullname == NULL) ? alias : fullname);
if (fullname == NULL) /* No alias found for user? */
{ /* No --> Try node lookup */
char user[MAXADDR];
char node[MAXADDR];
char path[MAXADDR];
char bucket[MAXADDR];
ExtractAddress(bucket, (char *) alias, FALSE);
user_at_node(bucket, path, node, user);
fullname = AliasByAddr( node, user);
if (fullname == NULL) /* Did we come up empty? */
{
char *hisuser, *hisnode;
hisuser = strtok( bucket, "@");
hisnode = strtok( NULL, "@");
if ((*bucket != '@') &&
equal(hisuser, user ) && (hisnode != NULL) &&
equal(hisnode, node ) && (strchr( node, '.') == NULL))
{
if (equal(hisnode, E_nodename))
strcpy(node, E_fdomain);
else {
strcat(node,".");
strcat(node,E_localdomain);
}
ExtractAddress(path, (char *) alias, TRUE);
if (strlen( path ) == 0)
sprintf(buffer,"%s@%s", hisuser, node );
else
sprintf(buffer,"\"%s\" <%s@%s>", path, hisuser, node);
fullname = buffer;
}
else
fullname = (char *) alias; /* Use original information */
}
}
else {
ExtractAddress(buffer,fullname,TRUE);
if (strlen(buffer) == 0) /* A list of users? */
{ /* Yes --> Do recursive call */
char *current = buffer; /* Current token being processed */
char *next = NULL; /* Next token to process */
strcpy(buffer,fullname);
do {
current = strtok(current,",\t "); /* Get next alias to process */
next = strtok(NULL,""); /* Also save rest of list */
header = ExplodeAlias( header , current, stream, resent);
/* Get alias, including sub-list */
current = next;
} while ( next != NULL ); /* Until no more tokens exist */
return header; /* Have written header, return */
} /* if */
} /* else */
if (strpbrk(fullname,"!@") == nil(char))
{
sprintf(buffer,"%s@%s", fullname , E_fdomain);
/* Local address */
fullname = buffer; /* Write out the formatted address */
}
PutHead(header, fullname, stream, resent);
/* Remote address */
return ""; /* Make header empty string for
next caller */
} /* ExplodeAlias */
/*--------------------------------------------------------------------*/
/* A p p e n d _ S i g n a t u r e */
/* */
/* Append the signature file to the specified mailbag file */
/* */
/* [Broke this code out from Send_Mail to support the ~a mail */
/* subcommand] */
/* */
/* Returns: 0 on success, 1 if signature file not found */
/*--------------------------------------------------------------------*/
static boolean Append_Signature(FILE *mailbag_fp ,